const { Schema } = require('mongoose');
const mongoose = require('./db');

const ArticleSchema = mongoose.Schema({
    title: { type: String, unique: true },
    cid: {
        type: Schema.Types.ObjectId,
        ref: "ArticleCate" // cid和文章分类建立关系  model
    }, // 分类 ID
    author_name: {
        type: String,
        default: "it营"
    },
    author_id: {
        type: Schema.Types.ObjectId,
        ref: "User",  // author_id和用户表建立关系  model
    }, // 用户ID
    description: String,
    content: String
})

module.exports = mongoose.model('Article', ArticleSchema, 'article');
